package com.wf.it.hpmqclientsms;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.study.it.sms.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SmsWorker {
    @Autowired
    private SmsUtil smsUtil;
    @RabbitListener(queues = "ask_sms")
    public void sendEmail(String json){
      JSONObject o= JSON.parseObject(json);
      String phone= (String) o.get("phone");
      String txt= (String) o.get("txt");
      String r=smsUtil.sendSms(phone,txt);
      System.out.println("发送短信给"+phone+",返回值为"+r);
    }
}
